package com.cheng.service;

import com.cheng.dao.ProductMapper;
import com.cheng.dao.RootMapper;
import com.cheng.pojo.Order;
import com.cheng.pojo.Root;
import com.cheng.pojo.User;
import com.cheng.pojo.Users;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

public class RootServiceImpl implements RootService {

    //service调dao层:组合Dao
    private RootMapper rootMapper;
    public void setRootMapper(RootMapper rootMapper) {
        this.rootMapper=rootMapper;
    }


    @Override
    public Root selectRoot(String username, String password) {
        return rootMapper.selectRoot(username,password);
    }

    @Override
    public PageInfo<Order> selectAllOrder(int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        List<Order> list = rootMapper.selectAllOrder();
        PageInfo<Order> pageInfo = new PageInfo<Order>(list);

        return pageInfo;
    }

    @Override
    public PageInfo<Users> queryuser(int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        List<Users> list = rootMapper.queryuser();
        PageInfo<Users> pageInfo = new PageInfo<Users>(list);

        return pageInfo;
    }

    @Override
    public int deleteuser(String name) {
        return rootMapper.deleteuser(name);
    }

    @Override
    public PageInfo<User> queryusers(int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        List<User> list = rootMapper.queryusers();
        PageInfo<User> pageInfo = new PageInfo<User>(list);

        return pageInfo;
    }

    @Override
    public int deleteusers(String userName) {
        return rootMapper.deleteusers(userName);
    }


}
